package org.googlecode.openapi_java;

import org.json.JSONException;
import org.json.JSONObject;

public class Album {
	private long aid;
	private long thumbId;
	private long ownerId;
	private String title;
	private String description;
	private long created;
	private long updated;
	private int size;
	private int privacy;

	public long getAid() {
		return aid;
	}

	public long getThumbId() {
		return thumbId;
	}

	public long getOwnerId() {
		return ownerId;
	}

	public String getTitle() {
		return title;
	}

	public String getDescription() {
		return description;
	}

	public long getCreated() {
		return created;
	}

	public long getUpdated() {
		return updated;
	}

	public int getSize() {
		return size;
	}

	public int getPrivacy() {
		return privacy;
	}

	public static Album fromJSON(JSONObject jsonObject) throws JSONException {
		Album album = new Album();
		System.out.println("Albums" + jsonObject);
		album.aid = jsonObject.getLong("aid");
		album.thumbId = jsonObject.getLong("thumb_id");
		album.ownerId = jsonObject.getLong("owner_id");
		album.title = jsonObject.getString("title");
		
		album.description = jsonObject.getString("description");
		album.created = jsonObject.getLong("created");
		album.updated = jsonObject.getLong("updated");
		
		album.size = jsonObject.getInt("size");
		if (jsonObject.has("privacy"))album.privacy = jsonObject.getInt("privacy");
		return album;
	}

	@Override
	public String toString() {
		return "Album{" + "aid=" + aid + ", thumbId=" + thumbId + ", ownerId="
				+ ownerId + ", title='" + title + '\'' + ", description='"
				+ description + '\'' + ", created=" + created + ", updated="
				+ updated + ", size=" + size + ", privacy=" + privacy + '}';
	}
}
